package com.shop.loan.proxy;

import cn.hutool.core.date.DateUtil;
import com.shop.loan.model.enums.OrderPoolType;
import com.shop.loan.model.view.LoanOrderByTodayPay;
import com.shop.loan.util.LoanOrderUtil;
import org.springframework.stereotype.Service;
import xyz.erupt.annotation.fun.DataProxy;
import xyz.erupt.annotation.model.Row;
import xyz.erupt.annotation.query.Condition;

import javax.annotation.Resource;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import java.util.Map;

@Service
public class LoanOrderByTodayUnPayProxy implements DataProxy<LoanOrderByTodayPay> {

    @Resource
    LoanOrderUtil loanOrderUtil;

    @Override
    public String beforeFetch(List<Condition> conditions) {
        conditions.clear();
        return null;
    }

    @Override
    public void afterFetch(Collection<Map<String, Object>> list) {
        list.clear();
        String startTime = DateUtil.beginOfDay(new Date()).toString();
        String endTime = DateUtil.endOfDay(new Date()).toString();
        loanOrderUtil.searchDayOrderList(list, OrderPoolType.today_tom_list.getType(), false, startTime, endTime);
        //列表显示字段完善
        loanOrderUtil.updateShowDayList(list);
    }

    @Override
    public List<Row> extraRow(List<Condition> conditions) {
        String startTime = DateUtil.beginOfDay(new Date()).toString();
        String endTime = DateUtil.endOfDay(new Date()).toString();
        return loanOrderUtil.searchDayOrderExtraRow(OrderPoolType.today_tom_list.getType(), false, startTime, endTime);
    }
}
